package com.paic.mhis.hcpms.common.validator;

import java.text.ParseException;
import java.util.Date;

import com.paic.mhis.common.util.DateUtil;


public class MapValueDateFormat extends MapValueValidator
{
	public MapValueDateFormat(String key, String msg, String code)
	{
		super(key, msg, code);
	}

	@Override
	protected boolean validateSuccess(Object value)
	{
		if(isEmpty(value))
			return true;
		if(!(value instanceof String))
			return false;
		String valueStr = (String)value;
		try
		{
			Date date = DateUtil.jsonDate2Date(valueStr);

			return DateUtil.jsonDate2String(date).equals(valueStr);
		}
		catch(ParseException e)
		{
			return false;
		}
	}

	protected Object[] getArguments(Object val)
	{
		return new Object[]{val};
	}
}
